package com.csii.security.store;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.provider.token.TokenEnhancer;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;

/**
 * jwt相关bean
 *
 * @author daixiaochun@csiisz.com
 */
//@Configuration 去掉JWT支持
public class JwtTokenConfig
{

    @Bean
    public TokenStore jwtTokenStore()
    {
        return new JwtTokenStore(jwtAccessTokenConverter());
    }

    @Value("${cola.security.jwt.signingKey}")
    private String signingkey;

    @Bean
    public JwtAccessTokenConverter jwtAccessTokenConverter()
    {
        JwtAccessTokenConverter accessTokenConverter = new JwtAccessTokenConverter();
        //TODO jwt 签名秘钥
        accessTokenConverter.setSigningKey(signingkey);
        return accessTokenConverter;
    }


}
